""" hexagon.py -- An oversimplified representation of a hexagon laid on a map

"""

import sys

#------------------------------------------------------------------------------
# classes
#------------------------------------------------------------------------------

class Hexagon(object):
    """ A representation of a specific hexagon on the map
    
    """

    def __init__(self, latitude, longitude):
        """ Take GPS coordinates and determine hexagon coordinates """
        self.init_latitude = latitude
        self.init_longitude = longitude

    def __repr__(self):
        """ Return a nice text description of this hexagon """
        repr = []
        repr.append("Hexagon")
        repr.append(".init point latitude: %s" % self.init_latitude)
        repr.append(".init point longitude: %s" % self.init_longitude)
        return "\n".join(repr)
    
#------------------------------------------------------------------------------
# utilities
#------------------------------------------------------------------------------
def show_usage():
    """ Print a usage message for direct callers """
    command = sys.argv[0]
    print
    print "%s" % command
    print
    print "usage:"
    print "     %s [<latitude> <longitude>]" % command
    print
    print "examples:"
    print "     %s                          # provide no pair (default is 0.0 0.0)" % command
    print "     %s 39.753658 -104.999382    # provide a pair of coordinates" % command
    print

# main
if __name__=="__main__":

    # accept user provided longitude and latitude if provided
    if len(sys.argv) not in (1,3):
        show_usage()
        sys.exit(1)
    elif len(sys.argv) == 3:
        latitude = sys.argv[1]
        longitude = sys.argv[2]
    else:
        latitude = 0.0
        longitude = 0.0

    # create a hexagon and output some information about it
    h = Hexagon(latitude, longitude)
    print h

